//
//  CheckInfoCell.m
//  KuWoCan
//
//  Created by hwd on 17/3/14.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "CheckInfoCell.h"
#import "OrderDetailCheckModel.h"

@implementation CheckInfoCell

/************************************************************************/

/**************************审核信息单元格***********************************/

/************************************************************************/


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    //创建列表
    _tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
    _tabView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tabView.estimatedRowHeight = 40.0;
    _tabView.rowHeight = UITableViewAutomaticDimension;
    _tabView.delegate = self;
    _tabView.dataSource = self;
    _tabView.scrollEnabled = NO;
    [self addSubview:_tabView];
    [_tabView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(@0);
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _checkArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"cellId";
    
    UITableViewCell *cell;
    cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    
    if (_checkArr && _checkArr.count > 0)
    {
        OrderDetailCheckModel *model = _checkArr[indexPath.row];
        
        UILabel *firstLab = [UILabel new];
        firstLab.textColor = [UIColor grayColor];
        firstLab.font = [UIFont systemFontOfSize:14.0];
        firstLab.textAlignment = NSTextAlignmentLeft;
        firstLab.text = [NSString stringWithFormat:@"%@,%@,%@",model.user.name,model.approverTime,model.approverMemo];
        [cell addSubview:firstLab];
        [firstLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@15);
            make.height.equalTo(@14);
            make.top.equalTo(@10);
            make.bottom.equalTo(@-10);
        }];
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 45;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headView = [UIView new];
    
    UIView *separatorView = [UIView new];
    separatorView.backgroundColor = KwColor(@"#eeeeee");
    [headView addSubview:separatorView];
    [separatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.top.equalTo(@0);
        make.height.equalTo(@10);
    }];
    
    UILabel *checkLab = [UILabel new];
    checkLab.textColor = [UIColor blackColor];
    checkLab.font = [UIFont systemFontOfSize:15];
    checkLab.textAlignment = NSTextAlignmentLeft;
    checkLab.text = @"审批信息";
    [headView addSubview:checkLab];
    [checkLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(separatorView.mas_bottom).offset(10);
        make.left.equalTo(@15);
        make.height.equalTo(@15);
    }];
    
    UIView *lineView = [UIView new];
    lineView.backgroundColor = KwColor(@"#eeeeee");
    [headView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.top.equalTo(checkLab.mas_bottom).offset(10);
        make.height.equalTo(@1.5);
    }];

    
    return headView;
}




@end
